package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.StaffMapper;
import com.domain.Staff;
import com.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class StaffServiceImpl
        extends ServiceImpl<StaffMapper, Staff>
        implements StaffService {

    @Autowired
    private StaffMapper staffMapper;

    @Override
    public List<Map<String, Object>> getStaff() {
        Object[] job = {"后端", "前端", "需求"};
        QueryWrapper<Staff> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("sex as 性别, count(*) as 人数")
                .in("job", job) // 可变参数，可传数组
                .or() // 上下两个条件为 or 关系
                .eq("job", "测试") // 只能传一个参数
                .gt("hiredate", "2020-01-05 15:30:20")
                .groupBy("sex");
        return staffMapper.selectMaps(queryWrapper);

    }


    @Override
    public List<Map<String, Object>> getStaffAndDepartment() {
        return staffMapper.getUserAll();
    }



}
